package com.example.myapplication.ui

import android.content.Context
import android.content.Intent
import android.graphics.drawable.Drawable
import android.os.Bundle
import androidx.appcompat.app.AppCompatActivity
import com.example.myapplication.databinding.ActivityAboutUsBinding

class AboutUsActivity : AppCompatActivity()  {

    private lateinit var binding: ActivityAboutUsBinding

    override fun onCreate(savedInstanceState: Bundle?) {
        super.onCreate(savedInstanceState)

        binding = ActivityAboutUsBinding.inflate(layoutInflater)
        setContentView(binding.root)

        val packageInfo = packageManager.getPackageInfo(packageName, 0)
        binding.tvVersion.text = "Version：当前版本：${packageInfo.versionName}"

        val appName = applicationContext
            .applicationInfo
            .loadLabel(packageManager)
            .toString()

        binding.tvAppName.text = appName

        val appIcon: Drawable = applicationContext.packageManager.getApplicationIcon(packageName)
        binding.div.setImageDrawable(appIcon)

        binding.ivBack.setOnClickListener { finish() }
    }

    companion object{
        fun start(context: Context){
            context.startActivity(Intent(context,AboutUsActivity::class.java))
        }
    }
}